package com.pkk.components.util;


import com.pkk.components.rpc.enums.CodeEnum;

/**
 * @description: 异常工具类
 * @author: peikunkun
 * @create: 2018-08-13 19:12
 **/
public class ExceptionUtil {

  /**
   * 返回状态码+状态描述
   *
   * @param codeEnum
   * @return
   */
  public static String getCodeAndMsg(CodeEnum codeEnum) {
    return codeEnum.getCode() + ":" + codeEnum.getMsg();
  }


  public static String getCodeCusMsg(CodeEnum codeEnum, String message) {
    return codeEnum.getCode() + ":" + message;
  }


  /**
   * @Description: 获取项目业务编码
   * @Param: codeEnum
   * @Param message
   * @Param businessCode
   * @return: java.lang.String
   * @Author: peikunkun
   * @Date: 2020/3/9 0009 下午 5:48
   */
  public static String getBusinessCodeMsg(CodeEnum codeEnum, String message, String businessCode) {
    StringBuffer sb = new StringBuffer("[");
    sb.append(businessCode);
    sb.append("]");
    sb.append(codeEnum.getCode());
    sb.append(":");
    sb.append(message);
    return sb.toString();
  }
}
